//
//  HomeCityViewController.m
//  QuickCure1
//
//  Created by 李江波 on 2016/10/31.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "HomeCityViewController.h"

@interface HomeCityViewController ()<UITableViewDataSource ,UITableViewDelegate>

@end

static NSString *cityID = @"cityID";

@implementation HomeCityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"选择城市";
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds];
    
    tableView.showsVerticalScrollIndicator = NO;
    
    [self.view addSubview:tableView];
    
    tableView.delegate = self;
    tableView.dataSource = self;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cityID];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.cityModels.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cityID forIndexPath:indexPath];
    
    cell.textLabel.text = self.cityModels[indexPath.row];
    
    return cell;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSString *cityName = self.cityModels[indexPath.row];
    
    [[NSNotificationCenter defaultCenter] postNotificationName:kIsUserChooseCityNotificationKey object:cityName];
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
}


@end
